<template>
  <el-dialog title="双击/回车 设备厂商" :visible.sync="dialogPersonVisible" center>
    <el-container>
      <el-header>
        <el-col :xs="9" :sm="9" :lg="9">
          <el-input v-model="dialogPerson.querypara" clearable placeholder="设备厂商名称"></el-input>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="12">
          <el-button type="primary"class="btn-search"  @click="dialogSearchPer" style="margin-left: 15px">查询
          </el-button>
        </el-col>
      </el-header>
      <el-main style="padding: 0">
        <el-table
          :data="perList"
          stripe
          @row-dblclick="dialogSelectPer"
          height="300"
          highlight-current-row>
          <el-table-column
            fixed
            label="设备厂商名称"
            width="150" align="center">
            <template slot-scope="scope">
              <span>{{scope.row.name}}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-main>
      <el-footer>
        <el-pagination
          background
          small
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          :page-sizes="[10,20,30, 50]" :page-size="listPerQuery.limit"
          :current-page="listPerQuery.page"
          @size-change="handleSizeChangePerSelect"
          @current-change="handlePerSelectCurrentChange"
          small
          style="margin-top: 10px;"
        ></el-pagination>
      </el-footer>
    </el-container>
  </el-dialog>
</template>

<script>
  /* eslint-disable */
  import {fetchPerList} from '@/api/organization/organization'
  export default {
    name: 'person-select-dialog',
    props: [
      'dialogSelectPerVisible'
    ],
    watch: {
      dialogPersonVisible: function (val) {
        this.$emit('update:dialogSelectPerVisible', val)
      },
      dialogSelectPerVisible: function (val) {
        this.dialogPersonVisible = val
        this.dialogPerson.querypara=''
        if(val){
          this.listPerQuery.page=1
          this.listPerQuery.limit=1
          this.getPerList()
        }
      }
    },
    mounted() {
      this.getPerList()
    },
    data() {
      return {
        perList: [],
        dialogPersonVisible: false,
        perListLoading: true,
        dialogPerson: {
          querypara: '',
          recordZw: ''
        },
        total: 10,
        listPerQuery: {
          page: 1,
          limit: 20
        }
      }
    },
    methods: {
      dialogSelectPer(row) {
        this.dialogPersonVisible = false
        this.$emit('selectPer', row)
      },
      dialogSearchPer() {
        this.getPerList()
      },
      handlePerSelectCurrentChange(val) {
        this.listPerQuery.page = val
        this.getPerList()
      },
      handleSizeChangePerSelect(val){
        this.listPerQuery.limit=val
        this.getPerList()
      }
    }

  }
</script>

<style scoped>
  .el-header{
    padding:0;
    border-bottom:none;
    margin-left: 5px;
  }
  .el-main{
    margin-top: 0px;
    margin-left: 5px;
  }
</style>
